package com.api.shopapi.service.impl;

import com.api.shopapi.entity.Order;
import com.api.shopapi.entity.OrderInfo;
import com.api.shopapi.entity.dto.OrderBusinessPersonalDTO;
import com.api.shopapi.entity.dto.OrderDTO;
import com.api.shopapi.mapper.OrderMapper;
import com.api.shopapi.service.OrderService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author maochuan
 */
@Service("OrderServiceImplOne")
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public int insert(Order order) {
        return orderMapper.insert(order);
    }

    @Override
    public int update(Order order) {
        return orderMapper.update(order);
    }

    @Override
    public int delete(String orderCode) {
        return orderMapper.delete(orderCode);
    }

    @Override
    public List<Order> getList() {
        return orderMapper.getList();
    }

    @Override
    public Order getByOrderCode(String orderCode) {
        return orderMapper.getByOrderCode(orderCode);
    }

    @Override
    public List<Order> getByUserCode(String userCode) {
        return orderMapper.getByUserCode(userCode);
    }


    //订单统计
    @Override
    public PageInfo<OrderInfo> getOrderInfo(int pageIndex, int pageSize, String governmentCode, String zoneCode) {
        PageHelper.startPage(pageIndex,pageSize);
        List<OrderInfo> orderInfoList=orderMapper.getOrderInfo(governmentCode,zoneCode);
        return  new PageInfo<>(orderInfoList);
    }


    @Override
    public PageInfo<OrderBusinessPersonalDTO> getOrderPersonal(int pageIndex, int pageSize, String receiveName,String receivePhone,String startTime,String endTime) {
        PageHelper.startPage(pageIndex,pageSize);
        List<OrderBusinessPersonalDTO> orderBusinessDTO = orderMapper.getOrderPersonal(receiveName,receivePhone,startTime,endTime);
        return new PageInfo<>(orderBusinessDTO);
    }

    @Override
    public List<Order> getOrderCreateTime(String elderlyCode, Date startTime, Date endTime) {
        return orderMapper.getOrderCreateTime(elderlyCode,startTime,endTime);
    }


}
